<template>

  <el-row type="flex" justify="space-between" align="middle" style="height: 40px; width:100%">
    <el-col :span="20">
      <i v-if="isRoot" class="el-icon-eleme" />
      <span>{{ nodeData.name }}</span>
    </el-col>
    <el-col :span="4">
      <el-row type="flex" justify="end">
        <!-- 两个内容 -->
        <el-col>{{ nodeData.manager }}</el-col>
        <el-col>
          <!-- 下拉菜单 element -->
          <el-dropdown>
            <span class="el-dropdown-link" @click.stop>
              操作<i class="el-icon-arrow-down" />
            </span>
            <!-- 下拉菜单 -->
            <template #dropdown>
              <el-dropdown-menu>
                <el-dropdown-item @click.native="adddepartments(nodeData.id)">添加子部门</el-dropdown-item>
                <el-dropdown-item v-if="!isRoot" @click.native="editdepartments(nodeData.id)">编辑部门</el-dropdown-item>
                <el-dropdown-item v-if="!isRoot" @click.native="deldepartments(nodeData.id)">删除部门</el-dropdown-item>
              </el-dropdown-menu>

            </template>
          </el-dropdown>
        </el-col>
      </el-row>
    </el-col>
  </el-row>

</template>

<script>
export default {
  props: {
    nodeData: {
      type: Object,
      required: true
    },
    isRoot: {
      type: Boolean,
      default: false
    }
  },
  created() {

  },
  methods: {
    // 删除部门
    deldepartments(id) {
      this.$emit('deldepartments', id)
    },

    // 添加子部门
    adddepartments(id) {
      console.log(111)
      console.log(id)
      this.$emit('adddepartments', id)
    },

    // 点击编辑部门,展现弹出框
    editdepartments(id) {
      this.$emit('editdepartments', id)
    }
  }
}
</script>

<style>

</style>
